cmake_minimum_required(VERSION 2.15)

project(vortex_onnx_trt)
add_definitions(-std=c++14)

option(CUDA_USE_STATIC_CUDA_RUNTIME ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CUDA_STANDARD 14)
find_package(CUDA REQUIRED)
enable_language(CUDA)

# enable all-plain target_link_libraries
set(CUDA_LIBRARIES PUBLIC ${CUDA_LIBRARIES})

set(CUDA_VER 12.1)
set(TRT_VER 8.6.1.6)

# SET(USER_OPENCV ON)

if(WIN32)
    # windows
    SET(OpenCV_INCLUDE_DIRS D:/Libs/opencv320/include/)
    SET(OpenCV_LIBRARY_DIRS D:/Libs/opencv320/lib/)
    SET(OpenCV_LIBS opencv_world320.lib)

    # SET(PROTOBUF_INCLUDE_DIRS D:/Libs/protobuf-3.11.4/include/)
    # SET(PROTOBUF_LIBRARY_DIRS D:/Libs/protobuf-3.11.4/lib/)
    # SET(PROTOBUF_LIBS libprotobuf)

    # cuda & tensorrt, modify as needed.
    include_directories("C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v${CUDA_VER}/include")
    link_directories("C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v${CUDA_VER}/lib/x64")
    include_directories("C:/Program Files/NVIDIA GPU Computing Toolkit/TensorRT-${TRT_VER}/include")
    link_directories("C:/Program Files/NVIDIA GPU Computing Toolkit/TensorRT-${TRT_VER}/lib")

    # stbimage
    include_directories("D:/Libs/stb_image/include/")
    # opencv
    include_directories(${OpenCV_INCLUDE_DIRS})
    link_directories(${OpenCV_LIBRARY_DIRS})

else()
    # unix like systems
    find_package(OpenCV 4 REQUIRED)

    # cuda & tensorrt
    include_directories(/usr/local/cuda/include)
    link_directories(/usr/local/cuda/lib64)
    include_directories(/usr/include/x86_64-linux-gnu/)
    link_directories(/usr/lib/x86_64-linux-gnu/)
    # stbimage
    include_directories(/usr/local/include)
    # opencv
    include_directories(${OpenCV_INCLUDE_DIRS})
    link_directories(${OpenCV_LIB_DIR})

    add_definitions(-O2 -pthread)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -g -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")
endif(WIN32)

# # build tensorrt plugin
# cuda_add_library(myplugins SHARED cuda/yololayer.cu)
# target_link_libraries(myplugins nvinfer cudart)

add_subdirectory(vortex-trt)
add_subdirectory(models/alexnet)
add_subdirectory(models/paddleclas_swin)
